# -*- coding: utf-8 -*-
from django.db import models
from django.utils import timezone

class Menus(models.Model):
    id = models.AutoField(primary_key=True,verbose_name="ID")
    name = models.CharField(max_length=50, blank=True, null=True,verbose_name="名称")
    icon = models.CharField(max_length=100, blank=True, null=True,verbose_name="小图标")
    page_url = models.CharField(max_length=100, blank=True, null=True,verbose_name="链接地址")
    menu_type = models.IntegerField(default=0,verbose_name="所属类型",choices=((1,"ICON类型"),(2,"ROLL类型")))
    parent_id = models.ForeignKey('self',on_delete=models.CASCADE, db_column='parent_id', verbose_name="所属菜单")
    sort = models.IntegerField(default=0, verbose_name="排序")
    create_date = models.DateTimeField(default=timezone.now, verbose_name="添加时间")
    def __str__(self): 
       return self.name
   
    class Meta:
        db_table = 'menu'
        verbose_name = "服务项目"    # 表名改成中文名
        verbose_name_plural = verbose_name


class MenusIntro(models.Model):
    id = models.AutoField(primary_key=True)
    content = models.TextField(verbose_name="内容说明")
    type = models.IntegerField(default=0,verbose_name="类型",choices=((1,"图片"),(0,"文章"))) 
    menu_id = models.ForeignKey(Menus, on_delete=models.CASCADE,verbose_name="所属菜单", choices=Menus.objects.values_list("id", "name"))
    sort = models.IntegerField(default=0, verbose_name="排序")
    style = models.CharField(max_length=50, blank=True, null=True, verbose_name="显示样式", choices=(("ad-index",".ad-index"),("title-big",".title-big"),("title-middle",".title-middle"))) 
    create_date = models.DateTimeField(default=timezone.now, verbose_name="添加时间")
    class Meta:
        db_table = 'menu_intro'
        verbose_name = "服务内容"    # 表名改成中文名
        verbose_name_plural = verbose_name
	
class OrderList(models.Model):
    order_no = models.CharField(max_length=30, primary_key=True, verbose_name="订单编号")
    order_price = models.IntegerField(default=0, verbose_name="订单价格")
    order_status = models.IntegerField(default=0, verbose_name="类型", choices=((0, "未支付"), (1, "已支付"), (2, "已服务"), (3, "已退款"))) 
    customer_name = models.CharField(default='', max_length=30, verbose_name="客户名称")
    customer_mobile = models.CharField(default='', max_length=18, verbose_name="客户手机")
    customer_address = models.TextField(default='', verbose_name="客户地址")
    service_date = models.DateTimeField(default=timezone.now, verbose_name="预约时间")
    create_date = models.DateTimeField(default=timezone.now, verbose_name="添加时间")

    def __str__(self): 
        return self.order_no
    class Meta:
        db_table = 'order_list'
        verbose_name = "订单列表"    # 表名改成中文名
        verbose_name_plural = verbose_name
        
class OrderDetail(models.Model):
    id = models.AutoField(primary_key=True)
    order_no = models.ForeignKey(to='OrderList', on_delete=models.CASCADE, to_field='order_no', verbose_name="订单编号")
    service_id = models.IntegerField(default=0,verbose_name="服务ID") 
    service_name = models.TextField(default='',verbose_name="服务名称")
    service_price = models.IntegerField(default=0, verbose_name="服务价格")
    create_date = models.DateTimeField(default=timezone.now, verbose_name="添加时间")
    def __str__(self): 
       return ''
    class Meta:
        db_table = 'order_detail'
        verbose_name = "订单明细"    # 表名改成中文名
        verbose_name_plural = verbose_name
    
        
class ServicePrice(models.Model):
    id = models.AutoField(primary_key=True)
    service_id = models.IntegerField(default=0,verbose_name="服务ID",choices=Menus.objects.values_list("id", "name")) 
    service_price = models.IntegerField(default=0,verbose_name="服务价格") 
    service_qr = models.TextField(default='',verbose_name="付款二维码") 
    update_date = models.DateTimeField(verbose_name="更新时间(每天只能使用一次)")
    create_date = models.DateTimeField(default=timezone.now, verbose_name="添加时间")
    class Meta:
        db_table = 'service_price'
        verbose_name = "服务价格"    # 表名改成中文名
        verbose_name_plural = verbose_name

class Personnel(models.Model):
    id = models.AutoField(primary_key=True)
    tags = models.CharField(max_length=256, blank=True, null=True, verbose_name="接单区，如五常，闲林")
    work_item = models.CharField(max_length=256, blank=True, null=True, verbose_name="工作类别")
    name = models.CharField(max_length=20, blank=True, null=True, verbose_name="姓名")
    sex = models.IntegerField(default=0, verbose_name="性别",choices=((1, "女"), (2, "男")))
    birthday = models.DateField(default='1980/01/01',verbose_name="出生年月")
    self_introduction = models.TextField(default='',verbose_name="自我简介")
    address = models.CharField(max_length=256, blank=True, null=True, verbose_name="居住地址")
    image = models.ImageField(default='',max_length=256,upload_to='uploadImages',verbose_name="身份证图片") 
    create_date = models.DateTimeField(default=timezone.now)
    
    def __str__(self): 
       return self.name
    class Meta:
        db_table = 'personnel'
        verbose_name = "简历管理"    # 表名改成中文名
        verbose_name_plural = verbose_name

class ThirdLogin(models.Model):
    id = models.AutoField(primary_key=True)
    open_id = models.CharField(max_length=80, blank=True, null=True)
    nick_name = models.CharField(max_length=50, blank=True, null=True) 
    app = models.CharField(max_length=8, blank=True, null=True)
    session_id = models.CharField(max_length=100, blank=True, null=True)
    create_date = models.DateTimeField(default=timezone.now)
    class Meta:
        db_table = 'third_login'
        

class SystemAd(models.Model):
    id = models.AutoField(primary_key=True)
    url = models.CharField(max_length=200, blank=True, null=True, verbose_name="广告链接")
    image = models.CharField(max_length=200, blank=True, null=True, verbose_name="广告图") 
    title = models.CharField(max_length=100, blank=True, null=True, verbose_name="广告标题")
    sort = models.IntegerField(default=0, verbose_name="排序")
    status = models.IntegerField(default=0, verbose_name="状态")
    create_date = models.DateTimeField(default=timezone.now, verbose_name="添加时间")
    class Meta:
        db_table = 'system_ad'
        verbose_name = "广告管理"    # 表名改成中文名
        verbose_name_plural = verbose_name